package com.fs.base.pojo;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import lombok.Data;
import lombok.EqualsAndHashCode;

import org.hibernate.annotations.Formula;

import com.fs.base.annotation.ColumnDesc;

/**
 * @author TiddlerCJ
 * @desc 系统菜单
 */
@Entity
@Table(name="s_menu")
@Data@EqualsAndHashCode(callSuper=false) 
public class Menu extends PkEntity{
	@ColumnDesc(name="菜单名称") 
	private String menuName;
	
	/*父菜单名称显示*/
	@Formula("(select m.menu_name from s_menu m where m.id = parent_id)")
	private String pMenuName;
	
	/*
	 * 关联按钮显示
	 */
	@Formula("(select group_concat(mm.motion_name) from s_menu_motion mm  WHERE mm.menu_id = id)")
	private String motions;
	
	@Formula("(select GROUP_CONCAT( CONCAT( mm.motion_id,'$$',mm.motion_name))  from s_menu_motion mm  WHERE mm.menu_id = id)")
	private String motionJson;
	
	@ColumnDesc(name="菜单地址") 
	private String menuUrl;
	
	@ColumnDesc(name="菜单图标") 
	private String menuIcon;
	
	@ColumnDesc(name="菜单排序") 
	private Integer menuOrder;
	
	@ColumnDesc(name="菜单父亲") 
	private String parentId;
	
	@ColumnDesc(name="是否根节点") 
	private String isLeaf;
	
	@Transient
	private String iconCls;
	
	public String getIconCls() {
		iconCls = menuIcon;
		return iconCls;
	}
}
